/**
 *Numbers.java
 *@anthor Daniel Liu
 *2006-5-10 ����03:34:48
 **/
package org.lex.utils;

public class Numbers {
	private static final Pair<Boolean, Integer> FALSE = new Pair<Boolean, Integer>(Boolean.FALSE, null);

	public static <T> Pair<Boolean, Integer> isInteger(T object) {
		return isInteger(object, 10);
	}

	public static <T> Pair<Boolean, Integer> isInteger(T object, int radix) {
		if (null == object)
			return FALSE;
		if (object instanceof Number)
			return Pair.wrap(Boolean.TRUE, ((Number) object).intValue());
		try {
			return Pair.wrap(Boolean.TRUE, Integer.parseInt(object.toString(), radix));
		} catch (Exception e) {
			return FALSE;
		}
	}

	private Numbers() {
	}
}
